{extend name='common/common' /}

{block name="style"}
<style type="text/css">
    .container-fluid .btn.btn-sm{
        float: right;
        margin-left: 10px;
    }
    .container-fluid{
        padding-right: 0px;
    }
	tbody tr{
		cursor: pointer;
	}
</style>
{/block}

{block name="content"}
<div class="wrapper wrapper-content animated fadeInRight">
    <!-- Panel Other -->
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>客户列表</h5>
        </div>
        <div class="ibox-content">
            <!--搜索框开始 pull-right-->
            <form id='commentForm' role="form" method="post" class="form-inline pull-left">
                <div class="content clearfix m-b">
                    <div class="form-group">
                        <label>姓名：</label>
                        <input type="text" class="form-control" id="name" name="name">
                    </div>
                    <div class="form-group">
                        <label>联系方式：</label>
                        <input type="text" class="form-control" id="phone" name="phone">
                    </div>
                    <div class="form-group">
                        <button class="btn btn-primary" type="button" style="margin-top:5px" id="search"><strong>搜 索</strong>
                        </button>
                    </div>
                </div>
            </form>
            <!--搜索框结束-->
            <div class="example-wrap">
                <div class="example">
                    <table id="cusTable">
                        <thead>
                        <th class="text-center" data-field="id">会员ID</th>
                        <th class="text-center" data-field="name">姓名</th>
                        <th class="text-center" data-field="phone">联系电话</th>
                        <th class="text-center" data-field="adress">地址</th>
                        <th class="text-center" data-field="qq">QQ</th>
                        <th class="text-center" data-field="weixin">微信</th>
                        <th class="text-center" data-field="relation">录入人</th>
                        <th class="text-center" data-field="time">录入时间</th>
						<!-- <th class="text-center" data-field="status">状态</th> -->
						<!-- <th class="text-center" data-field="remarks">备注</th> -->
                        </thead>
                    </table>
                </div>
            </div>
            <!-- End Example Pagination -->
        </div>
    </div>
</div>
<!-- End Panel Other -->
</div>
<input type="hidden" id="Mid" value="">
{/block}


{block name="script"}
<script type="text/javascript">
    function initTable() {
        //先销毁表格
        $('#cusTable').bootstrapTable('destroy');
        //初始化表格,动态从服务器加载数据
        $("#cusTable").bootstrapTable({
            method: "get",  //使用get请求到服务器获取数据
            url: "{:url('finance/memList')}", //获取数据的地址
            striped: true,  //表格显示条纹
            pagination: true, //启动分页
            pageSize: 10,  //每页显示的记录数
            pageNumber:1, //当前第几页
            pageList: [5, 10, 15, 20, 25],  //记录数可选列表
            sidePagination: "server", //表示服务端请求
						resizable:true,//可变宽列表
            paginationFirstText: "首页",
            paginationPreText: "上一页",
            paginationNextText: "下一页",
            paginationLastText: "尾页",
            queryParamsType : "undefined",
            columns : [{
                checkbox: false,
                formatter:function(value,row,index){
                    if (row.state == true){
                        return {
                            checked : value,//设置选中
                        };
                    }
                    return value;
                },
            }],
            queryParams: function queryParams(params) {   //设置查询参数
                var param = {
                    pageNumber: params.pageNumber,
                    pageSize: params.pageSize,
                    name:$('#name').val(),
                    phone:$('#phone').val(),
                    grade:$('#grade').val(),
                    status:$('#status').val(),
                };
                return param;
            },
            onLoadSuccess: function(res){ //加载成功时执行
                if(111 == res.code){
                    window.location.reload();
                }
                layer.msg("加载成功", {time : 1000});
            },
            onLoadError: function(){  //加载失败时执行
                layer.msg("加载数据失败");
            },
      			onDblClickRow:function(row){
              let m_id = row.id;
              console.log(row);
              parent.window.location.href = "{:url('finance/orderInput')}?m_id="+m_id;
              // $.get("{:url('finance/orderInput')}",{
              //     m_id:m_id
              // },function(data){
              //     console.log(data);
              //     parent.window.location.reload();
              //     parent.layer.closeAll();
              // });
      				// var oM_name=parent.document.getElementById('m_mame');
      				// var oM_id=parent.document.getElementById('m_id');
      				// var oM_relation=parent.document.getElementById('relation_id');
      				// var oM_time=parent.document.getElementById('time');
      				// parent.document.getElementById('phone').value = row.phone;
      				// var oM_adress=parent.document.getElementById('adress');
      				// var oM_nation=parent.document.getElementById('nation');
      				// var oM_id_card=parent.document.getElementById('id_card');
      				// var oM_birthday=parent.document.getElementById('birthday');
      				// oM_name.value = row.name;
      				// oM_id.value = row.id;
      				// oM_relation.value = row.relation_id;
      				// oM_time.value = row.time;
      				// oM_adress.value = row.adress;
      				// oM_nation.value = row.nation;
      				// oM_id_card.value = row.id_card;
      				// oM_birthday.value = row.birthday;
      				// parent.layer.closeAll();
      			}
        });
    }

    $(document).ready(function () {
        //调用函数，初始化表格
        initTable();

        //当点击查询按钮的时候执行
        $("#search").bind("click", initTable);
    });
</script>
{/block}
